package com.advertising.controls;

import java.util.List;

import javax.annotation.Resource;

import net.sf.json.JSONArray;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.advertising.biz.IEvaluateService;
import com.advertising.model.Evaluate;
import com.advertising.model.Release;
import com.tgyt.common.tools.page.Pagination;
import com.tgyt.framework.controls.struts2.BaseTg;
@Scope("prototype")
@Controller(value = "evaluateTgControl")
public class EvaluateTg extends BaseTg {
	@Resource(name = "evaluateService")
	private    IEvaluateService evaluateService;
	private  Evaluate evaluate;
	 
	private String linkerID;
	private String ADID;
	private String myAssess;
	private String pageNO;
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * 上传我的评价
	 * @return
	 */
	@SuppressWarnings("unused")
	private String sendAssess(){
		try {
			evaluate.setId(Integer.parseInt(linkerID));
			Release  release= new Release();
			release.setAid(Integer.parseInt(ADID));
			evaluate.setReleaseId(release);
			evaluate.setContent(myAssess);
			evaluateService.alter(evaluate);
			return "100000";
		} catch (Exception e) {
		   e.printStackTrace();
		 
		}
	
		return "0";
	}
	/**
	 * 查看新的评价
	 * @return
	 * @throws  
	 */
	private String  getMoreAssess(){
		try {
			StringBuffer result = new StringBuffer();
			evaluate.setId(Integer.parseInt(linkerID));
			Release  release= new Release();
			release.setAid(Integer.parseInt(ADID));
			Pagination pageList = 	evaluateService.getPageList(evaluate, Integer.parseInt(pageNO), rows, sort, order);
			List<Evaluate> list = pageList.getList();
			String	str = JSONArray.fromObject(evaluateService.convert(list)).toString();
	/*		 for (Evaluate evaluate : list) {
				result.append("#");
				result.append(evaluate.getContent());
				result.append("#");
			}*/
			return str;
		} catch (Exception e) {
			e.printStackTrace();
			 return null;
		}
	
	}
	
	
////////////////////////set get////////////////////


	public Evaluate getEvaluate() {
		return evaluate;
	}


	public void setEvaluate(Evaluate evaluate) {
		this.evaluate = evaluate;
	}
	public String getLinkerID() {
		return linkerID;
	}
	public void setLinkerID(String linkerID) {
		this.linkerID = linkerID;
	}
	public String getADID() {
		return ADID;
	}
	public void setADID(String aDID) {
		ADID = aDID;
	}
	public String getMyAssess() {
		return myAssess;
	}
	public void setMyAssess(String myAssess) {
		this.myAssess = myAssess;
	}
	public String getPageNO() {
		return pageNO;
	}
	public void setPageNO(String pageNO) {
		this.pageNO = pageNO;
	}
 
	
	
	
}
